package com.alex.statistics.global;


import com.alex.statistics.pojo.CodeEnum;
import com.alex.statistics.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 异常处理程序
 *
 * @author mbb
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

//    @ResponseBody
//    @ExceptionHandler(value = IllegalArgumentException.class)
//    public <String> Result<String> IllegalArgumentExceptionHandler(IllegalArgumentException e) {
//        return Result.msg(CodeEnum.exception, (String) e.getMessage());
//    }
    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public <String> Result<String> exceptionHandler(Exception e) {
        return Result.msg(CodeEnum.exception, (String) e.getMessage());
    }


}
